<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8" />
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
		<meta name="renderer" content="webkit|ie-comp|ie-stand" />
		<meta name="wiewport" content="width=device-width, initial-scale=1.0, maxinum-scale=1.0, user-scaleable=no" />
		<title>我的关注</title>
		<script type="text/javascript" src="/js/userCommon.js"></script>
	</head>

	<body class="main_body">
		<!--头部nav-->
		<div class="navbar navbar-default">
			<div class="container">
				<ul class="nav text-center quick_enter">
					<li><img src="/img/logo_login_03.jpg" class="nav_img" /></li>
					<li class="quick_enterli m-l-md">
						<a href="/entry.html">首页 </a>
					</li>
					<li class="quick_enterli">
						<a href="/theme.html" class="">强链接企业</a>
					</li>
					<li class="quick_enterli">
						<a href="/partner.html" class="">战略合作伙伴</a>
					</li>
					<li class="quick_enterli">
						<a href="/data.html" class="">数据看板</a>
					</li>
					<li class="dropdown pull-right admin_info">
						<img src="/img/shejishi_07.jpg" class="img-photo" />
						<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">
							<span id="user_span"></span> <span class="drop_caret"></span>
						</a>
						<ul class="dropdown-menu">
							<li>
								<a href="/usercenter/myAttention.html" ><i class="fa fa-user-secret"></i> 个人中心</a>
							</li>
							<li class="hidden" id="backPageEnter">
								<a href="javascript:void(0)" ><i class="fa fa-server"></i> 后台管理</a>
							</li>
							<li>
								<a href="javascript:void(0)" id="logout_a"><i class="fa fa-sign-out"></i> 退出登录</a>
							</li>
						</ul>
					</li>
				</ul>
			</div>
		</div>
		<!--主体-->
		<div class="container containerbox">
			<!--左边导航-->
			<div class="left_side">
				<div class="ibox">
					<h3 class="topTitle">个人中心</h3>
					<ul class="leftMeun">
						<li class="active">
							<a href="/usercenter/myAttention.html"><i class="fa fa-unlink" aria-hidden="true"></i> 我的关注</a>
						</li>
						<li class="">
							<a href="/usercenter/businessManage.html"><i class="fa fa-weixin" aria-hidden="true"></i> 企业管理</a>
						</li>
						<li class="">
							<a href="/usercenter/partnerManage.html"><i class="fa fa-user-times" aria-hidden="true"></i>合作伙伴管理</a>
						</li>
						<li class="">
							<a href="/usercenter/businessInfoManage.html"><i class="fa fa-wrench" aria-hidden="true"></i> 链接互动管理</a>
						</li>
						<li>
							<a href="/usercenter/needManage.html"><i class="fa fa-wrench" aria-hidden="true"></i> 企业需求管理</a>
						</li>
						<!-- <li class="">
							<a href="/usercenter/partnerManage.html"><i class="fa fa-user-times" aria-hidden="true"></i>合作伙伴管理</a>
						</li> -->
						<li class="">
							<a href="/usercenter/personalSettings.html"><i class="fa fa-user-times" aria-hidden="true"></i>个人设置</a>
						</li>
					</ul>
				</div>

			</div>
			<!--右边-->
			<div class="right_side">
				<div class="ibox">
					<div class="ibox-content" >
						<table class="table_at">
							<tr class="ac_title">
								<th style="width: 10%;">序号</th>
								<th style="width: 75%;">企业名称</th>
								<th style="width: 15%;">操作</th>
							</tr>
							<tbody id="list">
			
							</tbody>
						</table>
					</div>
				</div>
			</div>
		</div>
		<!--footer-->
		<div class="footer" id="footerA"> </div>
		<script type="text/javascript">
			$(document).ready(function(){
				if($.cookie('Authorization')===null || localStorage.getItem('realname') === null) {
					showErr("您处于未登录状态，请先登录", '1000000');
					return
				}
				$('#user_span').text(localStorage.getItem('realname') )

				// 取消关注点击
				$('#list').on('click', '.do-cancle', function() {
					var id = $(this).attr('add-id')
					var that = this
					top.confirm("您确定要取消关注吗", "", function(isConfirm) {
						if(isConfirm) {
							$.ajax({
								// url: service_url + '/a/personal/attentEnterprise/attent?eid='+id +'&token=' + $.cookie('Authorization'),
								url: service_url + '/a/zhiku/attentZkEntInfo/attent?eid='+id +'&token=' + $.cookie('Authorization'),
								type: 'GET',
								xhrFields: {
									withCredentials: true
								},
								crossDomain: true,
								contentType: 'application/json',
								dataType: 'jsonp',
								jsonpCallback:"success_jsonpCallback",  
								processData: false, // 告诉jQuery不要去处理发送的数据
								success: function(data) {
									if (data.status === '00') {
										var msg = data.msg
										if (msg === '取消关注成功！') {
											top.alert(msg,'','',{type: 'success'})
											loadList()
										} else {
											showErr('取消关注失败！')
										}

									} else {
										showErr(data.msg)
									}
								},
								error: function(XMLHttpRequest, textStatus, errorThrown) {
									console.log(XMLHttpRequest, textStatus, errorThrown)
								}
							})
						} else {
							//after click the cancel
						}
					}, {
						confirmButtonText: '确定',
						cancelButtonText: '取消',
						width: 400
					});
				})
				
				loadList()
			})
			
			// 查询关注列表
			function loadList() {
				$.ajax({
					url: service_url + '/a/zkUser/getUserAttentEnt?token=' + $.cookie('Authorization'),
					type: 'GET',
					xhrFields: {
						withCredentials: true
					},
					crossDomain: true,
					contentType: 'application/json',
					dataType: 'jsonp',
					jsonpCallback:"success_jsonpCallback",  
					processData: false, // 告诉jQuery不要去处理发送的数据
					success: function(data) {
						if (data.status === '00') {
							var list = JSON.parse(data.data)
							var tempHtml = ''
							$('#list').empty()
							for (var i = 0;i < list.length;i++) {
								tempHtml = tempHtml  + '<tr><td>'+(i+1)+'</td><td><a target="_blank" href=/detail.html?id='+list[i].eid+' target="_blank">'+list[i].entName+'</a></td><td><span class="do-cancle" add-id="'+list[i].eid+'">取消关注</span></td></tr>'
								// tempHtml = tempHtml + '<li><p class="pull-right"><button type="button" class="btn btn-xs btn-success btn-outline" add-id="'+list[i].eid+'">取消关注</button></p><a target="_blank" href=/detail.html?id='+list[i].eid+' target="_blank">'+list[i].entName+'</a></li>'
							}
							$('#list').append(tempHtml)
						} else {
							showErr(data.msg)
						}
					},
					error: function(XMLHttpRequest, textStatus, errorThrown) {
						showErr('获取我关注的企业失败！')
						console.log(XMLHttpRequest, textStatus, errorThrown)
					}
				})
			}
		</script>
	</body>

</html>